package com.sesame.controller;

import com.sesame.bean.DbInfo;
import kim.sesame.framework.web.controller.AbstractWebController;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author johnny
 * @date 2017-06-10 13:10
 * @classpath com.sesame.controller
 * @Description:
 */
@CommonsLog
@Controller
@RequestMapping("/index")
public class IndexController  extends AbstractWebController {

    /**
     * 加载页面
     *
     * @return
     */
    @RequestMapping("/select")
    public String select(HttpServletRequest request) {

        DbInfo bean = (DbInfo) request.getSession().getAttribute("dbinfo");
        if (bean == null) {
            return "index";
        } else {
            return "select";
        }
    }

    @RequestMapping("/{uriPath}")
    public String index(@PathVariable("uriPath") String uriPath) {
        return uriPath;
    }

    @RequestMapping("/page404")
    public String page404() {
        return "error/404";
    }

    @RequestMapping("/page500")
    public String page500() {
        return "error/500";
    }
}